#include "main_window.h"
#include <qlayout.h>
#include <qgroupbox.h>
#include <qvgroupbox.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qhbuttongroup.h>

MainWindow::MainWindow():QDialog(0, "Environment Variables"),
                         user_vars_(Env::USER), sys_vars_(Env::MACHINE)
{

    setCaption("Environment Variables");
    setFixedSize(QSize(380, 420));
    
    //user part
    QGroupBox*  user_group = new QVGroupBox(this, "User variables");
    user_group->setTitle("User variables");
    user_table_ = new QListView(user_group);
    user_table_->addColumn("Variables");
    user_table_->addColumn("Value");

    QHButtonGroup* user_button_group = new QHButtonGroup(user_group);
    //QBoxLayout* user_hbox =  new QHBoxLayout(user_group);
    QPushButton* user_new_button = new QPushButton("New", user_button_group);
    QPushButton* user_delete_button = new QPushButton("Edit", user_button_group);
    QPushButton* user_edit_button = new QPushButton("Delete", user_button_group);
    //QSpacerItem* user_spacer = new QSpacerItem(400, 20,QSizePolicy::Expanding, QSizePolicy::Minimum );
    
    //user_hbox->addItem(user_spacer);
    //user_hbox->addWidget(user_new_button);
    //user_hbox->addWidget(user_delete_button);
    //user_hbox->addWidget(user_edit_button);
    
    
    //machine part
    QGroupBox*  sys_group  = new QVGroupBox(this, "System variables");
    sys_group->setTitle("System variables");
    
    sys_table_ = new QListView(sys_group);
    sys_table_->addColumn("Varables");
    sys_table_->addColumn("Value");


    //button group
    QBoxLayout* hbox = new QHBoxLayout(20);
    QPushButton* ok_button = new QPushButton("OK", this);
    QPushButton* cancel_button = new QPushButton("Cancel", this);
    QSpacerItem* spacer = new QSpacerItem(400, 20,QSizePolicy::Expanding, QSizePolicy::Minimum );
        
    hbox->addItem(spacer);    
    hbox->addWidget(ok_button);
    hbox->addWidget(cancel_button);

    
    QBoxLayout* main_vbox  = new QVBoxLayout(this);
    main_vbox->setMargin(10);
    main_vbox->addWidget(user_group);
    main_vbox->addWidget(sys_group);
    main_vbox->addLayout(hbox);
    
}
